package com.soundking.server.service.impl;

import com.soundking.server.SystemCache;
import com.soundking.server.service.WxWorkService;
import com.xuhe.wx.dto.WxWorkMsgDTO;
import com.xuhe.wx.utils.wxWork.WeixinWorkApiUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Slf4j
@Service
public class WxWorkServiceImpl implements WxWorkService {
    @Autowired
    private RestTemplate restTemplate;

    @Override
    public void refreshAccessToken() {
        String accessToken = WeixinWorkApiUtil.refreshAccessToken(restTemplate, SystemCache.wxWorkAppId, SystemCache.wxWorkAppSecret);
        if (accessToken != null) {
            SystemCache.wxWorkAccessToken.set(accessToken);
        }
    }
}
